#include "settingswindow.h"
#include <QMessageBox>

SettingsWindow::SettingsWindow(QWidget *parent)
    : QDialog(parent) {
    setWindowTitle("游戏设置");

    // 创建标题标签
    titleLabel = new QLabel("游戏设置", this);
    titleLabel->setAlignment(Qt::AlignCenter);
    titleLabel->setStyleSheet("font-size: 20px; font-weight: bold; margin-bottom: 10px;");

    // 创建 AI 开关
    aiEnabledCheckBox = new QCheckBox("启用 AI", this);

    // 创建按钮
    okButton = new QPushButton("确定", this);
    cancelButton = new QPushButton("取消", this);

    // 创建布局
    QVBoxLayout *mainLayout = new QVBoxLayout(this);
    mainLayout->addWidget(titleLabel);
    mainLayout->addWidget(aiEnabledCheckBox);
    mainLayout->addWidget(okButton);
    mainLayout->addWidget(cancelButton);

    // 连接按钮点击信号到槽函数
    connect(okButton, &QPushButton::clicked, this, &SettingsWindow::onOkButtonClicked);
    connect(cancelButton, &QPushButton::clicked, this, &SettingsWindow::onCancelButtonClicked);
}

void SettingsWindow::onOkButtonClicked() {
    // 获取 AI 是否启用
    bool aiEnabled = aiEnabledCheckBox->isChecked();
    QMessageBox::information(this, "设置", QString("AI 已 %1").arg(aiEnabled ? "启用" : "禁用"));
    accept(); // 关闭窗口
}

void SettingsWindow::onCancelButtonClicked() {
    reject(); // 关闭窗口
}
